<!DOCTYPE html>
<html lang="zh-CN">

@include('/base.head')
<body>
@include('/business.topNav')
<div class="container-fluid">
    <div class="row">
        @extends('business.leftNav')
        <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
            <h2 class="page-header">我的商品 | <button type="button" class="btn btn-primary  btn-sm" data-toggle="modal" data-target="#addArea">上架商品</button></h2>
            @if(session('__Ajax_RedirectFunc_status') == true)
                <div>
                    <div class="alert alert-success alert-dismissible fade in" role="alert">
                        <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                        </button>
                        <h3>成功</h3>
                        <p><?php echo session('__Ajax_RedirectFunc_message');?></p>
                        <p><?php echo session('__Ajax_RedirectFunc_plugin');?></p>
                    </div>
                </div>
            @endif
            @if(session('__Ajax_RedirectFunc_status') === false)
                <div >
                    <div class="alert alert-danger alert-dismissible fade in" role="alert">
                        <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                        </button>
                        <h3>失败</h3>
                        <p><?php echo session('__Ajax_RedirectFunc_message');?></p>
                        <p><?php echo session('__Ajax_RedirectFunc_plugin');?></p>
                    </div>
                </div>
            @endif
            <div class="panel-body" >
                <div class="modal fade" id="addArea" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                    <div class="modal-dialog">
                        <div class="modal-content">
                            <div class="modal-header">
                                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                                <h4 class="modal-title" id="myModalLabel">上架商品</h4>
                            </div>
                            <div class="modal-body">
                                <form enctype="multipart/form-data" class="form-horizontal" role="form" action="/addGoods" method="post">
                                    <input type="hidden" name="_token" value="{{ csrf_token() }}">
                                    <h5>商品名称</h5>
                                    <input type="text"  name="goods_name" class="form-control" placeholder="商品名称"  required autofocus><br>
                                    <h5>商品样图</h5>
                                    <input name="files" type="file"> <br>
                                    <h5>商品类别</h5>
                                    <select name="goods_class" class="form-control">
                                        @foreach($goodsClass as $value)
                                            <option value="{{$value->goods_class_id}}">{{$value->goods_class_name}}</option>
                                        @endforeach
                                    </select><br>
                                    <h5>商品介绍</h5>
                                    <input type="text"  name="goods_info" class="form-control" placeholder="商品介绍"  required autofocus><br>
                                    <h5>商品价格</h5>
                                    <input type="text"  name="goods_price" class="form-control" placeholder="商品价格"  required autofocus><br>
                            </div>
                            <div class="modal-footer">
                                <button type="submit" class="btn btn-primary">上架</button>
                                <button type="button" class="btn btn-default" data-dismiss="modal">返回</button>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            <table class="table table-responsive table-condensed table-hover table-striped">
                <thead>
                <tr>
                    <th>商品样图</th>
                    <th>商品名称</th>
                    <th>商品类别</th>
                    <th>商品介绍</th>
                    <th>上架时间</th>
                    <th>商品价格</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                @foreach($goodsData as $data)
                    <tr>
                        <td>
                            <img style="width: 100px;height: 100px" src="/images/{{$data->goods_image}}">
                        </td>
                        <td>{{$data->goods_name}}</td>
                        <td>{{$data->goods_class_name}}</td>
                        <td>{{$data->goods_info}}</td>
                        <td>{{$data->goods_time}}</td>
                        <td>{{$data->goods_price}}元</td>
                        <td><!--<button type="button" class="btn btn-warning  btn-sm" data-toggle="modal" data-target="#upArea{{$data->goods_id}}">修改</button>-->
                        <a href="/moreGoods/{{$data->goods_id}}" type="button" class="btn btn-info  btn-sm">详情</a>
                            <button type="button" class="btn btn-danger  btn-sm" data-toggle="modal" data-target="#delArea{{$data->goods_id}}">下架</button>
                        </td>
                    </tr>
                    <!--修改模态框-->
                    <div class="modal fade" id="upArea{{$data->goods_id}}" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                        <div class="modal-dialog">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                                    <h4 class="modal-title" id="myModalLabel2">当前商品：{{$data->goods_name}}</h4>
                                </div>
                                <div class="modal-body">
                                    <form enctype="multipart/form-data" class="form-horizontal" role="form" action="/upGoods" method="post">
                                        <input type="hidden" name="_token" value="{{ csrf_token() }}">
                                        <input type="hidden" name="goods_id" value="{{$data->goods_id}}">
                                        <h5>商品名称</h5>
                                        <input type="text"  name="goods_name" class="form-control" placeholder="商品名称" value="{{$data->goods_name}}" required autofocus><br>
                                        <h5>商品样图</h5>
                                        <input name="files" type="file"> <br>
                                        <h5>商品介绍：</h5>
                                        <input type="text"  name="goods_info" class="form-control" placeholder="商品介绍" value="{{$data->goods_info}}" required autofocus><br>
                                        <h5>商品价格：</h5>
                                        <input type="number"  name="goods_price" class="form-control" placeholder="商品价格" value="{{$data->goods_price}}" required autofocus><br>
                                </div>
                                <div class="modal-footer">
                                    <button type="submit" class="btn btn-warning">修改</button>
                                    <button type="button" class="btn btn-default" data-dismiss="modal">返回</button>
                                    </form>
                                </div>
                            </div>
                        </div>
                    </div>
                    <!--删除模态框-->
                    <div class="modal fade" id="delArea{{$data->goods_id}}" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                        <div class="modal-dialog">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                                    <h4 class="modal-title" id="myModalLabel2">警告!</h4>
                                </div>
                                <div class="modal-body">
                                    <form action="/delGoods" method="get">
                                        <input type="hidden" name="_token" value="{{ csrf_token() }}">
                                        <input type="hidden" name="goods_id" value="{{$data->goods_id}}">
                                        <h4>确定要下架此商品吗？</h4>
                                </div>
                                <div class="modal-footer">
                                    <button type="submit" class="btn btn-danger">下架</button>
                                    <button type="button" class="btn btn-default" data-dismiss="modal">返回</button>
                                    </form>
                                </div>
                            </div>
                        </div>
                    </div>
                @endforeach
                </tbody>
            </table>
                <ul class="list text-center">
                    {{$goodsData->links()}}
                </ul>
        </div>
    </div>
</div>
</body>
</html>